
const request = (config) => {
	// 处理 apiUrl
<<<<<<< HEAD
	// config.url = 'http://192.168.5.115:8080' + config.url;
	config.url = 'https://meiye.hddig.com' + config.url;
=======
	
	 var url =config.url.replace("/","");
	 // config.url = 'http://192.168.5.115'+ '/ad' + url;
	 
	config.url = 'https://meiye.hddig.com' + '/ad' + url;
	
>>>>>>> dev
	// config.dataType = config.dataType
config.method =="get"? 	config.header= {
		 'content-Type': 'application/json; charset=UTF-8'
		 
	}:	config.header= {
		'content-Type': 'application/x-www-form-urlencoded;'
	}
	  const token = uni.getStorageSync('token');
	  if(token){
		    config.header = {
		             token
		           };
	  }

	if (!config.data) {
		config.data = {};
	}
	// console.log(JSON.stringify(config.data));
	let promise = new Promise(function(resolve, reject) {
		uni.request(config).then(responses => {
			// 异常
			
			console.log(responses)
			if(responses[1].data.code==102){
				uni.showToast({
					'icon':'none',
					title:responses[1].data.data
				})
			}
			if(responses[1].data.code ==112){
				uni.showToast({
					'icon':'none',
					title:responses[1].data.data
				})
			}
			if(responses[1].data.code ==103){
				uni.showToast({
					'icon':'none',
					title:responses[1].data.data
				})
			}
			if(responses[1].data.code==114){
				uni.showToast({
					'icon':'none',
					title:responses[1].data.data
				})
			}
			if(responses[1].data.code==104){
				uni.showToast({
					'icon':'none',
					title:responses[1].data.data
				})
			}
			if(responses[1].data.code==500){
				uni.showToast({
					'icon':'none',
					title:responses[1].data.data
				})
			}
			if(responses[1].data.code==120){
				uni.showToast({
					'icon':'none',
					title:responses[1].data.data
				})
			}
			if(responses[1].data.code==132){
				uni.showToast({
					'icon':'none',
					title:responses[1].data.data
				})
			}
			// if(responses[1].data.code==200){
			// 	uni.showToast({
			// 		'icon':'none',
			// 		title:responses[1].data.data
			// 	})
			// }
			if(responses[1].data.code==129){
				uni.showToast({
					'icon':'none',
					title:responses[1].data.data
				})
			}
			resolve(responses)
		
		}).catch(error => {
			// reject(error);
			uni.showToast({
				title:'请求超时，请稍后重试',
				icon:'none'
			})
		})
	})
	return promise;
};



export default request;



